package com.bw.zhuangao5___day002.Fragment.Movies.One.Day3;

import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.bw.mvp.V.BannerActivity;
import com.bw.mvp.V.BannerFragment;
import com.bw.zhuangao5___day002.Fragment.Movies.One.Day3.SQL.SQLoneday3;
import com.bw.zhuangao5___day002.R;

public class MoviesOneDay3_Activity extends BannerActivity {


    private ImageView oneday3IMG;
    private TextView oneday3Text1;
    private TextView oneday3Text2;
    private TextView oneday3Text3;
    private Button oneday3Butt;

    @Override
    public int bandLayoud() {
        return R.layout.activity_movies_one_day3_;
    }

    @Override
    public void initView() {


        oneday3IMG = (ImageView) findViewById(R.id.oneday3_IMG);
        oneday3Text1 = (TextView) findViewById(R.id.oneday3_text1);
        oneday3Text2 = (TextView) findViewById(R.id.oneday3_text2);
        oneday3Text3 = (TextView) findViewById(R.id.oneday3_text3);
        oneday3Butt = (Button) findViewById(R.id.oneday3_butt);
    }

    @Override
    public void initDate() {
//
//        intent3.putExtra("name",listha.get(position).getTitle());
//        intent3.putExtra("pic",listha.get(position).getPic());
//        intent3.putExtra("stringnum",listha.get(position).getCollect_num());
//        intent3.putExtra("cailiao",listha.get(position).getFood_str());
//        intent3.putExtra("num",listha.get(position).getNum());
        Intent intent = getIntent();
        String name = intent.getStringExtra("name");
        String pic = intent.getStringExtra("pic");
        String stringnum = intent.getStringExtra("stringnum");
        String cailiao = intent.getStringExtra("cailiao");
        int num = intent.getIntExtra("num", 100);

        oneday3Text1.setText("" + name);
        oneday3Text2.setText("" + cailiao);
        oneday3Text3.setText("" + stringnum);

        Glide.with(this).load(pic).into(oneday3IMG);

        oneday3Butt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SQLoneday3 sqLoneday3 = new SQLoneday3( MoviesOneDay3_Activity.this,"quyang.db",null,1);
                SQLiteDatabase writableDatabase = sqLoneday3.getWritableDatabase();
                writableDatabase.execSQL("insert into quyang values(?,?,?,?,?)",new Object[]{
                        name,pic,stringnum,cailiao,num
                });

                ToastUtils.showShort("加入购物车成功");
            }
        });

    }
}
